package BNS.wheat;

import java.io.Serializable;
import BNS.plumbing.*;
import BNS.graphs.*;

/** A class used by WheatMktGame to hold all data pertinent to a particular player
	(aka Client) (aka ClientLiaison).
	*/
class NodeState implements java.io.Serializable {
	
	int index;	// your node index number
	float endowment, acquired;		// what I have, what I have gotten
	float sellingPrice, sellingVolume;	// rate I'm offering for sale, and the amount
	float bestPrice;	// the best rate someone is offering me (for positive amount!)
	
	transient ClientLiaison client;	// gadget handling communication with player of this node
	transient Market market;		// quantitative model of economic environment of this node
	
	/** constructor giving default values to various variables. 
		@param idx the graph's index of the node for which this object is being created. 
		@param d the initial endowment (amount of commodity player starts with)
		*/
	public NodeState(int idx, float d) {
		index= idx; 
		endowment= d; 
		acquired= 0.f; 
		sellingPrice= Float.MAX_VALUE; 
		sellingVolume= 0;
		bestPrice= Float.MAX_VALUE; 
		}
	
	public String toString() {
		return String.format("%2d %6f %6f, %6g %6g; %6g", index,
			endowment, acquired, Math.min(sellingPrice,9999), sellingVolume, Math.min(bestPrice,999));
		}
	}
